#include "UseMultiMutexBest.h"

#include <random>

using namespace std;

UseMultiMutexBest::UseMultiMutexBest() {}

void UseMultiMutexBest::inc() {

	// random n s sleep
	default_random_engine generator;
	uniform_int_distribution<int> distribution(1, 5);
	// c++ 17
	// scoped_lock m12(m1, m2);
	UseMultiMutexBest::count++;
	this_thread::sleep_for(chrono::seconds(distribution(generator)));

}

uint64_t UseMultiMutexBest::get_count() {
	return UseMultiMutexBest::count;
}

UseMultiMutexBest::~UseMultiMutexBest() {}

// define static variable
uint64_t UseMultiMutexBest::count = 0;
mutex UseMultiMutexBest::m1;
mutex UseMultiMutexBest::m2;